﻿<!DOCTYPE html>
<!--承包商入场人员名单liebiao-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        body {
            padding-bottom: 10px;
        }

        .el-dialog__body {
            height: 100% !important;
        }

        .el-dialog.is-fullscreen {
            overflow: hidden !important;
        }
    </style>
    <style>
        .el-table__body-wrapper table tbody tr td {
            text-align: center;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form ref="form" :inline="true" label-position="right" label-width="100px" style="margin-bottom: 15px;"
            :model="formInline" class="demo-form-inline" >

            <el-row>
                <el-col class="head-tool">
                    
<div class="new_title fl"><strong><img src="/static/images/icon1.png" />承包商入场人员名单</strong></div>
                    <span>
                        <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3" @click="onSubmit">
                        </btn>
                        <btn text="入场添加" linetype="3" imgsrc="/static/images/add.png" @click="UserInput('tj')">
                        </btn>
                        <!--<btn-uploadfile-list url="xxxx" linetype="3"></btn-uploadfile-list>
                        <btn-export-list url="xxxx" :forminline="this.formInline" linetype="3">
                        </btn-export-list>-->

                        <btn text="确认离场" linetype="3" imgsrc="/static/images/general.png" @click="Lichang('xg')">
                        </btn>

                        <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                    </span>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <!--v-model="formInline.model.ContractorName"
    :placeholder="ContractorAdmissionList.ContractorName"-->
                                <template slot="prepend">
                                    {{ContractorAdmissionList.ContractorName+mark.m}}
                                </template>
                                <el-select @visible-change="visibleChange" v-model="formInline.model.CBSListId" slot="suffix"
                                           :placeholder="ContractorPersonnelDirectory.ContractorName">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in CBS_Lists" :label="item.contractorName"
                                               :value="item.id"></el-option>
                                </el-select>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input v-model="formInline.model.mark02"
                                :placeholder="ContractorAdmissionList.AdmissionName" size="mini">
                                <template slot="prepend">
                                    {{ContractorAdmissionList.AdmissionName+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <!--v-model="formInline.model.Region" :placeholder="ContractorAdmissionList.Region"-->
                                <template slot="prepend">
                                    {{ContractorAdmissionList.Region+mark.m}}
                                </template>
                                <treeselect v-model="Region" :options="TreeData" :flat="true"
                                            slot="suffix" placeholder="请选择区域"
                                            style="line-height: 28px;" />
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>


                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{ContractorAdmissionList.AdmissionTime+'开始'+mark.m}}
                                </template>
                                <el-date-picker v-model="formInline.model.TimeArrayBegin" type="date" slot="suffix"  value-format="yyyy-MM-dd"
                                    size="mini" placeholder="选择日期">
                                </el-date-picker>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="12" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{ContractorAdmissionList.AdmissionTime+'结束'+mark.m}}
                                </template>
                                <el-date-picker v-model="formInline.model.TimeArrayEnd" type="date" slot="suffix"  value-format="yyyy-MM-dd"
                                    size="mini" placeholder="选择日期">
                                </el-date-picker>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>


            </el-row>
        </el-form>

        <el-table stripe ref="table" :data="ListItem.tableData" :height="ListItem.tableHeight" border
                  @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%">
            <el-table-column type="selection" align="center" width="55">
            </el-table-column>
            <el-table-column type="index" :label="ContractorDirectory.SerialNumber" :index="indexMethod" width="50"
                             show-overflow-tooltip="true"></el-table-column>

            <el-table-column prop="mark01" :label="ContractorAdmissionList.ContractorName" min-width="180"
                             show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="mark02"
                             :label="ContractorAdmissionList.AdmissionName" min-width="120" show-overflow-tooltip="true">
            </el-table-column> <!--:formatter="getDicValue"-->

            <el-table-column prop="regionText" :label="ContractorAdmissionList.Region" min-width="80"
                             show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="admissionTime" :label="ContractorAdmissionList.AdmissionTime" :formatter="myformatDate"
                             show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="departureTime" :label="ContractorAdmissionList.FactoryTime" :formatter="myformatDate"
                             show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="admissionConfirmerText" :label="ContractorAdmissionList.AdmissionConfirmer"
                             min-width="120" show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="factoryConfirmerText" :label="ContractorAdmissionList.FactoryConfirmer" min-width="120"
                             show-overflow-tooltip="true">
            </el-table-column>


            <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                <template slot-scope="scope">
                    <button type="button" class="elst-bt-xg" @click=UserEdit('xg',scope.row.id)>
                        <i class="el-icon-edit"></i>
                    </button>
                </template>
            </el-table-column>
        </el-table>
        <el-row type="flex" justify="end">
            <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                :layout="ListItem.layout" :total="ListItem.total">
            </el-pagination>
        </el-row>
        <el-dialog title="承包商入场人员名单" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%"
            height="80%" top="10vh" fullscreen="true">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        Vue.component('treeselect', VueTreeselect.Treeselect)
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    //mydata: PersonInChargeTree,
                    //区域
                    TreeData: [],
                    CBS_Lists: [],
                    ConstructionCategory: [],
                    ListItem: ListItem,
                    Region: null,
                    formInline: {
                        model: {
                            CreateFactory: '',
                            mark02: '',
                            Region: '',
                            AdmissionTime: '',
                            ContractorName: '',
                            TimeArrayBegin: '',
                            TimeArrayEnd: '',
                            CBSListId: ''

                        },
                        offset: 0,
                        limit: 10
                    }
                }
            }, created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            //watch: {
            //    //下拉树监控
            //    Region(val, oldval) {
            //        this.Region = val;
            //    }
            //},
            mounted: function () {
                //获取下拉菜单内容
                //this.ConstructionCategory = getDicData('25');

                this.TreeData = GetAreaTreeData(this, this.formInline.model.CreateFactory);
                this.getCBS_List();
                //初始化数据
                this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                getDicValue: function (row, column, cellValue, index) {
                    if (cellValue) {
                        if (typeof cellValue === 'string' || typeof cellValue === 'number') {
                            return getTreeValue(this.mydata, cellValue)
                        }
                        else {
                            var result = '';
                            for (var i = 0; i < cellValue.length; i++) {
                                result += getTreeValue(this.mydata, cellValue[i]) + ',';
                            }
                            result = result.substr(0, result.length - 1);
                            return result;
                        }
                    }

                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },

                handleNodeClick: function (data) {
                    console.log(data);
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/CBS_IntoFactoryUser/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "ContractorPersonnelAdmissionEdit.html", id); },

                Lichang: function () {
                    if (this.ListItem.tableMultipleSelection.length == 0) {
                        showMessage(msg.AtLeastOne, 'error')
                        return;
                    }
                    var delIds = [];
                    for (var i = 0; i < this.ListItem.tableMultipleSelection.length; i++) {
                        var item = this.ListItem.tableMultipleSelection[i];
                        delIds.push(item.id);
                    }
                    myAjax("post", this, '/api/CBS_IntoFactoryUser/Lichang', delIds, function (response) {
                        app.GetPageData(1);
                        this.ListItem.currentPage = 1;
                        showMessage(msg.OperatingOk, "success");
                    });
                },

                UserEdit: function (val, id) { DialogShow(this, val, "ContractorPersonnelAdmissionEdit.html", id); },
                //获取分页数据
                GetPageData: function (currentIndex) {
                    this.formInline.model.Region = this.Region;
                    GetPageData(this, currentIndex, '/api/CBS_IntoFactoryUser/GetList')
                },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                //初始化承包商下拉框
                getCBS_List: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/CBS_List/GetList', { model: { status: '', CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                        mythis.CBS_Lists = response.data.pageData;
                        console.log('h1', response.data.pageData);
                    }, false);
                },
            }
        });
        function MenuHelper(list, pid) {
            var result = [];

            list.forEach(function (v, i) {
                if (!v.parentId) v.parentId = guidEmpty;
                if (v.parentId == pid) {
                    var obj = v;
                    obj.id = obj.id + '';
                    obj.label = obj.name + '';
                    obj.icon = 'tree-item';
                    var nextObj = MenuHelper(list, v.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                        obj.icon = 'tree-open';
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
    </script>
</body>

</html>